chicken_0116 chicken_0131 (so hard to distinguish) chicken_0181 chicken_0218 chicken_0264 chicken_0306 chicken_0383 chicken_0761 chicken_0646 chicken_0599 (only a leg) chicken_0891 (dark color) chicken_0999
dog_0010 dog_0021 (typical hair) dog_0023 dog_0033 dog_0095 dog_0146 (only a leg) dog_0147 dog_0342 (smooth surface) dog_0404 dog_0432 dog_0608 dog_0887
Some outliers in the whole dataset exist and may result in prediction errors.
Some ideas: - Extract surface texture which stands out with curvy grains (? hard to realize) - Color RGB feature (success) - Color HSV feature
Change to Greyscale, blue and red channels
file.bw=list()
file.bl=list()
file.red=list()
for (i in 1:5){
file.bw[[i]]=channel(filename[[i]],mode="grey")
display(file.bw[[i]])
}
for (i in 1:5) {
file.bl[[i]]=channel(filename[[i]], mode='asblue')
display(channel(filename[[i]], mode='asblue'))
}
for (i in 1:5) {
file.red[[i]]=channel(filename[[i]], mode='asred')
display(channel(filename[[i]], mode='asred'))
}
Extract the texture by high contrast on blue channel, which really shows difference to me between fried chicken and dogs.
file.contrast=list()
for (i in 1:5){
file.contrast=file.bl[[i]]*5
display(file.bl[[i]]*5)
}
filter_high <- matrix(1, nc = 3, nr = 3)
filter_high[2, 2] <- -8
file.hi=list()
for (i in 1:5){
file.hi <- filter2(filename[[i]], filter_high)
display(file.hi)# high pass
}
for (i in 1:5){
file.bw[[i]]=channel(filename[[i]],mode="grey")
img_seg1 <- thresh(file.bw[[i]], w=60, h=60, offset=0.06)
display(img_seg1, all=TRUE)
}
#Oriented Contour ### didn't see any use
img_leaf=list()
img_leaf1=list()
oc=list()
for (i in 1:5){
img_leaf[[i]] <- resize(filename[[i]], 128, 128)
img_leaf[[i]] <- channel(img_leaf[[i]], mode="gray")
img_leaf1[[i]] <- thresh(img_leaf[[i]], w=50, h=50, offset=0.05)
display(img_leaf1[[i]])}
for (i in 1:5){
oc[[i]] <- ocontour(bwlabel(img_leaf1[[i]]))
plot(oc[[i]][[1]], type='l');points(oc[[i]][[1]], col=2)
}
#Local Curvature
lc=list()
i=list()
neg=list()
pos=list()
for (k in 1:5){
lc[[k]] <- localCurvature(x=oc[[k]][[1]], h=11)
i[[k]] <- lc[[k]]$curvature >= 0
neg[[k]] <- array(0, dim(img_leaf1[[k]]))
pos[[k]] <- neg[[k]]
pos[[k]][lc[[k]]$contour[i[[k]],]+1] <- lc[[k]]$curvature[i[[k]]]
neg[[k]][lc[[k]]$contour[!i[[k]],]+1] <- -lc[[k]]$curvature[!i[[k]]]
display(10*(rgbImage(pos[[k]], , neg[[k]])), title = "Image curvature")
}
Color Features from RGB
By discretizing the RGB values, we can get a set of color features. We subdivide the pixel values in each color channel into multiple bands of equal width. Then the counts of pixels in correponding bins consist of a set of color features that characterizes the color distribution of the image.
str(rgb_feature)
List of 5
$ : num [1:800] 0.01379 0.02122 0.02635 0.02134 0.00368 ...
$ : num [1:800] 0.00301 0.01485 0.01819 0.02569 0.02503 ...
$ : num [1:800] 7.88e-06 1.38e-03 8.54e-03 9.58e-03 3.15e-04 ...
$ : num [1:800] 0.001236 0.005528 0.006125 0.000306 0 ...
$ : num [1:800] 0.01459 0.01061 0.01105 0.00498 0.00152 ...